﻿@model PermissionTreeListViewModel
@{
    var x = Html.X();

    var panel = x.TabPanel().Buttons(
        x.Button().Text("提交").Icon(Icon.Disk)
            .DirectEvents(de =>
            {
                de.Click.Action = "Save";
                de.Click.ExtraParams.Add(new Parameter("owner", Request["owner"].ToString()));
                de.Click.ExtraParams.Add(new Parameter("ownerId", Request["ownerId"].ToString()));
                de.Click.ExtraParams.Add(new Parameter("ids", "App.Grid.GetTreeValues(this)", ParameterMode.Raw));
                de.Click.EventMask.ShowMask = true;
                de.Click.EventMask.Msg = "正在提交...";
                de.Click.Success = "App.Edit.PostBackSuccess";
            })
        ,
        x.Button().Text("关闭").Icon(Icon.Cancel).OnClientClick("App.Edit.CloseWindow(this)")
        );

    panel.Layout(LayoutType.Fit);

    var trees = new List<TreePanel>();
    foreach (var system in Model.Systems)
    {
        var item = x.TreePanel().Border(false).AutoScroll(true).Lines(true)
            .RootVisible(false).HideHeaders(true).Animate(false).Root(Model.LeftTrees[system.Code]).ColumnModel(
                new TreeColumn()
                {
                    DataIndex = "text",
                    Flex = 1
                })
            .Listeners(li =>
            {
                li.ItemClick.Handler = "App.Main.onTreeItemClick(record, e);";
                li.CheckChange.Fn = "App.Grid.checkedChildNodes";
            });
        if (Model.Systems.Count > 1)
        {
            item.Title(system.Name);
        }
        trees.Add(item);
    }
    panel.Items(trees);
}
@(
        x.Window().Layout(LayoutType.Fit)
            .CloseAction(CloseAction.Destroy)
            .Width(585).Height(450)
            .Items( panel)
)